import { defineComponent,inject,computed,h } from "vue";

export const RouterView = defineComponent({
  name:"RouterView",
  props:{
    to: {
      type: String,
      required: true,
    },
  },
  setup(props,{}){
    const injectedRoute:any = inject("currentRouteKey")!
    const currentRoute:any = computed(()=>{
      return injectedRoute.value;
    })
    // console.log(injectedRoute);
    const routerInstance:any = inject("routerInstanceKey")!
    return ()=>{
      const rt = routerInstance?.gerRouter(currentRoute.value.path);
      return h(rt.component,props.to)
    }
  }
})